import type { GM_registerMenuCommand, Types } from "tm";

export interface XhrError {
  error: "noxhr" | "abort" | "error" | "timeout" | "Via timeout";
  resp?: Types.Xhr.Response;
}

export interface HikerResponse {
  readonly finalUrl: string;
  readonly headers: Record<string, string[]>;
  readonly readyState:
    | typeof XMLHttpRequest.UNSENT
    | typeof XMLHttpRequest.OPENED
    | typeof XMLHttpRequest.HEADERS_RECEIVED
    | typeof XMLHttpRequest.LOADING
    | typeof XMLHttpRequest.DONE;
  readonly response: typeof XMLHttpRequest.prototype.response;
  readonly responseHeaders: ReturnType<
    typeof XMLHttpRequest.prototype.getAllResponseHeaders
  >;
  readonly responseJSON: string;
  readonly responseText: typeof XMLHttpRequest.prototype.responseText;
  readonly responseURL: typeof XMLHttpRequest.prototype.responseURL;
  readonly status: typeof XMLHttpRequest.prototype.status;
  readonly statusText: typeof XMLHttpRequest.prototype.statusText;
}

export interface ListObject {
  标识: string;
  地址: string;
  在线更新: boolean;
  筛选后存储: boolean;
}

export interface Rule {
  black: "black" | "white";
  type: 0 | 1 | 2 | 3;
  sel: string;
  generic: boolean;
  place: string;
}

export interface BRule {
  match: string | string[];
  level: 0 | 1 | 2 | 3;
  rule: string;
}

export interface CssObject {
  needUpdate: boolean;
  genHideCss: string;
  genExtraCss: string;
  spcHideCss: string;
  spcExtraCss: string;
}

export interface MenuItem {
  id: ReturnType<typeof GM_registerMenuCommand> | undefined;
  readonly text: () => Promise<string>;
}

export type ETagObject = Record<string, string>;
export type AbpObject = Record<string, string>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AnyFunction = (...arguments_: any[]) => any;
